import Vue from 'vue'
import { _get, _post } from './httpWrap'
import symbolManager from 'assets/symbolManager'

const request: any = {
    // server端对接的http接口均在此声明(调用$get | $delete | $post | $put)
    // 如有需要,可在最后一个参数中指定其他域名({ baseURL: 'http://192.168.20.186:80' }),该项参数可选
    // 新增：fromThirdOrg参数，为true时可避免url被自动添加组织名，默认为false，如下例
    // succ会在server端成功返回response时调用

    allapps (succ, fail): void {
        _get('api/config/allapps', succ, fail, { baseURL: 'http://192.168.20.186:80', fromThirdOrg: true })
    }
}
export default new Proxy(request, {
    get (target, key) {
        return new Proxy(target[key], {
            apply (target, ctx, args) {
                Object.defineProperty(Vue.prototype, symbolManager.get('httpConfig'), {
                    value: args[args.length - 1],
                    writable: false,
                    configurable: true
                })
                return Reflect.apply(target, ctx, args)
            }
        })
    }
})
